package com.yupi.yuaicodemother.core;

import com.yupi.yuaicodemother.ai.model.MultiFileCodeResult;
import com.yupi.yuaicodemother.core.parser.CodeParserExecutor;
import com.yupi.yuaicodemother.core.parser.MultiFileCodeParser;
import org.junit.jupiter.api.Test;

import java.util.regex.Pattern;

/**
 * @Author: LZY
 * @CreateTime: 2025-10-08
 * @Description:
 * @Version: 1.0
 */

public class MUltiFileCodeParserTest1 {


    @Test
    void test01() {
        MultiFileCodeParser multiFileCodeParser = new MultiFileCodeParser();

        MultiFileCodeResult result = multiFileCodeParser.parseCode(contest);

        System.out.println(result);

    }

    String contest = """
            # 任务记录网站
                        
            我将创建一个简洁、响应式的任务记录网站，包含添加任务、标记完成和删除任务的功能。
                        
            ```html
            <!DOCTYPE html>
            <html lang="zh-CN">
            <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>任务记录</title>
                <link rel="stylesheet" href="style.css">
            </head>
            <body>
                <div class="container">
                    <header>
                        <h1>任务记录</h1>
                        <p>管理您的日常任务</p>
                    </header>
                        
                    <main>
                        <section class="add-task">
                            <form id="task-form">
                                <input type="text" id="task-input" placeholder="输入新任务..." required>
                                <button type="submit">添加任务</button>
                            </form>
                        </section>
                        
                        <section class="task-list">
                            <h2>任务列表</h2>
                            <div id="tasks-container">
                                <!-- 任务将在这里动态生成 -->
                            </div>
                        </section>
                    </main>
                        
                    <footer>
                        <p>&copy; 2023 任务记录网站</p>
                    </footer>
                </div>
                        
                <script src="script.js"></script>
            </body>
            </html>
            ```
                        
            ```css
            /* 全局样式 */
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
                        
            body {
                font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                line-height: 1.6;
                color: #333;
                background-color: #f5f5f5;
            }
                        
            .container {
                max-width: 800px;
                margin: 0 auto;
                padding: 20px;
                min-height: 100vh;
                display: flex;
                flex-direction: column;
            }
                        
            /* 头部样式 */
            header {
                text-align: center;
                margin-bottom: 30px;
                padding: 20px;
                background-color: #fff;
                border-radius: 8px;
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            }
                        
            header h1 {
                color: #2c3e50;
                margin-bottom: 10px;
            }
                        
            header p {
                color: #7f8c8d;
            }
                        
            /* 添加任务区域 */
            .add-task {
                margin-bottom: 30px;
                background-color: #fff;
                padding: 20px;
                border-radius: 8px;
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            }
                        
            #task-form {
                display: flex;
                gap: 10px;
            }
                        
            #task-input {
                flex: 1;
                padding: 12px;
                border: 1px solid #ddd;
                border-radius: 4px;
                font-size: 16px;
            }
                        
            #task-form button {
                padding: 12px 20px;
                background-color: #3498db;
                color: white;
                border: none;
                border-radius: 4px;
                cursor: pointer;
                font-size: 16px;
                transition: background-color 0.3s;
            }
                        
            #task-form button:hover {
                background-color: #2980b9;
            }
                        
            /* 任务列表样式 */
            .task-list {
                flex: 1;
                background-color: #fff;
                padding: 20px;
                border-radius: 8px;
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            }
                        
            .task-list h2 {
                margin-bottom: 20px;
                color: #2c3e50;
                border-bottom: 1px solid #eee;
                padding-bottom: 10px;
            }
                        
            .task-item {
                display: flex;
                align-items: center;
                padding: 15px;
                border-bottom: 1px solid #eee;
                transition: background-color 0.3s;
            }
                        
            .task-item:hover {
                background-color: #f9f9f9;
            }
                        
            .task-item:last-child {
                border-bottom: none;
            }
                        
            .task-checkbox {
                margin-right: 15px;
                width: 20px;
                height: 20px;
                cursor: pointer;
            }
                        
            .task-text {
                flex: 1;
                font-size: 16px;
            }
                        
            .task-text.completed {
                text-decoration: line-through;
                color: #95a5a6;
            }
                        
            .task-actions {
                display: flex;
                gap: 10px;
            }
                        
            .delete-btn {
                background-color: #e74c3c;
                color: white;
                border: none;
                padding: 8px 12px;
                border-radius: 4px;
                cursor: pointer;
                transition: background-color 0.3s;
            }
                        
            .delete-btn:hover {
                background-color: #c0392b;
            }
                        
            .empty-message {
                text-align: center;
                color: #95a5a6;
                padding: 30px;
                font-style: italic;
            }
                        
            /* 底部样式 */
            footer {
                text-align: center;
                margin-top: 30px;
                padding: 20px;
                color: #7f8c8d;
                font-size: 14px;
            }
                        
            /* 响应式设计 */
            @media (max-width: 768px) {
                .container {
                    padding: 10px;
                }
               \s
                #task-form {
                    flex-direction: column;
                }
               \s
                .task-item {
                    flex-direction: column;
                    align-items: flex-start;
                }
               \s
                .task-checkbox {
                    margin-bottom: 10px;
                }
               \s
                .task-actions {
                    margin-top: 10px;
                    width: 100%;
                    justify-content: flex-end;
                }
            }
            ```
                        
            ```javascript
            // 任务管理应用
            document.addEventListener('DOMContentLoaded', function() {
                // 获取DOM元素
                const taskForm = document.getElementById('task-form');
                const taskInput = document.getElementById('task-input');
                const tasksContainer = document.getElementById('tasks-container');
               \s
                // 从本地存储加载任务
                let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
               \s
                // 初始化渲染任务列表
                renderTasks();
               \s
                // 添加任务事件监听
                taskForm.addEventListener('submit', function(e) {
                    e.preventDefault();
                   \s
                    const taskText = taskInput.value.trim();
                   \s
                    if (taskText) {
                        // 创建新任务对象
                        const newTask = {
                            id: Date.now(),
                            text: taskText,
                            completed: false
                        };
                       \s
                        // 添加到任务数组
                        tasks.push(newTask);
                       \s
                        // 保存到本地存储
                        saveTasks();
                       \s
                        // 重新渲染任务列表
                        renderTasks();
                       \s
                        // 清空输入框
                        taskInput.value = '';
                    }
                });
               \s
                // 渲染任务列表
                function renderTasks() {
                    // 清空容器
                    tasksContainer.innerHTML = '';
                   \s
                    // 如果没有任务，显示提示信息
                    if (tasks.length === 0) {
                        tasksContainer.innerHTML = '<p class="empty-message">暂无任务，添加一个任务开始吧！</p>';
                        return;
                    }
                   \s
                    // 创建任务元素
                    tasks.forEach(task => {
                        const taskElement = document.createElement('div');
                        taskElement.className = 'task-item';
                        taskElement.dataset.id = task.id;
                       \s
                        taskElement.innerHTML = `
                            <input type="checkbox" class="task-checkbox" ${task.completed ? 'checked' : ''}>
                            <span class="task-text ${task.completed ? 'completed' : ''}">${task.text}</span>
                            <div class="task-actions">
                                <button class="delete-btn">删除</button>
                            </div>
                        `;
                       \s
                        tasksContainer.appendChild(taskElement);
                       \s
                        // 添加复选框事件监听
                        const checkbox = taskElement.querySelector('.task-checkbox');
                        checkbox.addEventListener('change', function() {
                            toggleTaskCompletion(task.id);
                        });
                       \s
                        // 添加删除按钮事件监听
                        const deleteBtn = taskElement.querySelector('.delete-btn');
                        deleteBtn.addEventListener('click', function() {
                            deleteTask(task.id);
                        });
                    });
                }
               \s
                // 切换任务完成状态
                function toggleTaskCompletion(taskId) {
                    tasks = tasks.map(task => {
                        if (task.id === taskId) {
                            return { ...task, completed: !task.completed };
                        }
                        return task;
                    });
                   \s
                    saveTasks();
                    renderTasks();
                }
               \s
                // 删除任务
                function deleteTask(taskId) {
                    tasks = tasks.filter(task => task.id !== taskId);
                    saveTasks();
                    renderTasks();
                }
               \s
                // 保存任务到本地存储
                function saveTasks() {
                    localStorage.setItem('tasks', JSON.stringify(tasks));
                }
            });
            ```
                        
            ## 功能说明
                        
            这个任务记录网站具有以下功能：
                        
            1. **添加任务**：在输入框中输入任务内容，点击"添加任务"按钮
            2. **标记完成**：点击任务前的复选框可以标记任务为完成状态
            3. **删除任务**：点击任务右侧的"删除"按钮可以删除任务
            4. **数据持久化**：使用localStorage保存任务数据，刷新页面不会丢失
            5. **响应式设计**：在桌面和移动设备上都能良好显示
                        
            网站采用简洁现代的UI设计，使用柔和的配色方案，确保良好的用户体验。
                        
            """;


}